package atomlist;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.SynchronousQueue;

/**
 * @功能
 * @创建时间 2019/12/25
 *
 */
public class T09_SynchronusQueue {
    public static void main(String[] args) throws InterruptedException {
        BlockingQueue<String> strs = new SynchronousQueue<>(); // 容量为0
        new Thread(()->{
            while (true) {
            try{
                System.out.println(strs.take());
            } catch (InterruptedException e) {
                e.printStackTrace();
            }}
        }).start();
        strs.put("aaa");// 阻塞等待消费者消费，就是一种特殊的transfer
        strs.put("bbb");// 阻塞等待消费者消费，就是一种特殊的transfer
     //   strs.add("aaa");
        System.out.println(strs.size());
    }
}
